package Operator;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

public class Addoperator implements IOPerator{
    @Override
    public void work(BookList bookList) {
        System.out.println("增加图书");
        Scanner scanner = new Scanner((System.in));
        System.out.println("请输入图书名字");
        String name = scanner.nextLine();
        System.out.println("请输入图书作者");
        String author = scanner.nextLine();
        System.out.println("请输入图书定价");
        int price = scanner.nextInt();
        scanner.nextLine();
        System.out.println("请输入图书类型");
        String type = scanner.nextLine();

        int bookcount = bookList.getListsize();
        if(bookcount == 10){
            System.out.println("书架已满");
            return;
        }
        Book book = new Book(name,author,price,type);
        bookList.set_book(book,bookcount);
        bookList.setListsize(bookcount + 1);
        System.out.println("添加成功");
    }
}
